clear*
set maxvar 11000

global date _2025_10_28
cd "/Users/atri0032/Dropbox/World Bank/Temperature, poverty, and inequality/Estimations/"

********************************************************************************************************
********************************** Table S16: Controlling for other country's characteristics
********************************************************************************************************

// Subnational level
* FE model 
use "${date}/_data/spid_for_analysis_v2.dta", clear

drop sample

local controls 		ln_GDPppp Unempilo agri manuf popgr 
local controls_ext 	ln_GDPppp Unempilo agri manuf edupri eduter popgr tech broad_money consumption_exp inflation life_expectancy rule_of_law_pct trade voice_acc_pct
 
local controls_1 	ln_GDPppp Unempilo agri manuf popgr edupri eduter
local controls_2 	ln_GDPppp Unempilo agri manuf popgr trade broad_money consumption_exp inflation
local controls_3 	ln_GDPppp Unempilo agri manuf popgr life_expectancy
local controls_4	ln_GDPppp Unempilo agri manuf popgr rule_of_law_pct voice_acc_pct
local controls_5 	ln_GDPppp Unempilo agri manuf popgr edupri eduter trade broad_money consumption_exp inflation life_expectancy rule_of_law_pct voice_acc_pct

// Poverty
estimates clear
qui reghdfe poor215 temp rainfall_sum humid `controls_1', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m1
qui reghdfe poor215 temp rainfall_sum humid `controls_2', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m2
qui reghdfe poor215 temp rainfall_sum humid `controls_3', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m3
qui reghdfe poor215 temp rainfall_sum humid `controls_4', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m4
qui reghdfe poor215 temp rainfall_sum humid `controls_5', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m5

local opts ///
	cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_country N_subregion r2, fmt(0 0 0 3) ///
	label("Observations" "No of countries" "No of regions" "R-squared")) ///
	eqlabels(none) mtitle("+edu" "+macro" "+life" "+inst" "+all") ///
	collabels(,none) varlabels(temp "Temperature" rainfall_ave "Rainfall" humid "Humidity") varwidth(25) ///
	title("Table S17 - Subnational - FE - Poverty")	
	
esttab m*, `opts'
esttab m* using "${date}/_tables/_tab_s16_poverty.csv", replace `opts'

	
// Inequality
estimates clear
qui reghdfe gini temp rainfall_sum humid `controls_1', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m1
qui reghdfe gini temp rainfall_sum humid `controls_2', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m2
qui reghdfe gini temp rainfall_sum humid `controls_3', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m3
qui reghdfe gini temp rainfall_sum humid `controls_4', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m4
qui reghdfe gini temp rainfall_sum humid `controls_5', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle	
	levelsof code if e(sample), local(count1)
	local Ncountry1 : word count `count1'
	estadd scalar N_country = `Ncountry1'
	levelsof geo_code2_new if e(sample), local(count2)
	local Ncountry2 : word count `count2'
	estadd scalar N_subregion = `Ncountry2'
	est store m5	
	
local opts ///
	cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_country N_subregion r2, fmt(0 0 0 3) ///
	label("Observations" "No of countries" "No of regions" "R-squared")) ///
	eqlabels(none) mtitle("+edu" "+macro" "+life" "+inst" "+all") ///
	collabels(,none) varlabels(temp "Temperature" rainfall_ave "Rainfall" humid "Humidity") varwidth(25) ///
	title("Table S16 - Subnational - FE - Inequality")	
	
esttab m*, `opts'
esttab m* using "${date}/_tables/_tab_s16_inequality.csv", replace `opts'

	
